﻿    using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HomeWork
{
    internal class RandomArray
    {        
        int[] randomArray { get; set; }




        public RandomArray(int count) : this(count, 0, 10)
        {
           
        }

        public RandomArray(int count, int minvalue) : this (count, minvalue, 10)
        {
            
        }

        public RandomArray(int count, int minvalue, int difference)
        {
            if (count <= 0)
                throw new ArgumentException("数组长度必须大于0", nameof(count));

            if (difference <= 0)
                throw new ArgumentException("差值范围必须大于0", nameof(difference));

      

            Random random = new Random();
            randomArray = new int[count]; //创建一个指定长度的数组
            randomArray[0] = minvalue;          //设置第一个元素为起始值
            int sum = minvalue; //初始化和为起始值           

            for (int i = 1; i < count; i++)
            {
                randomArray[i] = random.Next(sum, sum + difference); //生成1到100之间的随机数
                sum = randomArray[i];
            }
            
        }

        public int[] get()
        {
            return randomArray;
        }
    }
}
